home *** CD-ROM | disk | FTP | other *** search
- Path: qcd.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Binary Tree and MSC/C++7.00
- Date: 7 Jan 1996 17:37:39 GMT
- Organization: Los Alamos National Laboratory
- Distribution: world
- Message-ID: <4cp0d3$e75@newshost.lanl.gov>
- References: <HAKOLA.96Jan7002825@lk-hp-16.hut.fi>
- NNTP-Posting-Host: qcd.lanl.gov
-
- In article <HAKOLA.96Jan7002825@lk-hp-16.hut.fi>, hakola@snakemail.hut.fi
- (Petri Hakola) writes:
- |>
- |> It seems to me that I suffer some kind of partial amnesia. I
- |> can build a binary tree, add stuff to it, but how do I destroy
- |> it. I've tried nearly everyting, but there's either General
- |> Protection Error or some remains of prior members. I have
- |> quite embarassing feeling that I have forget something so
- |> obvious that it should almost 'hit the eye', but...
- |>
- |> if(root == NULL)
- |> return;
- |> delete_tree(root->left);
- |> free(root);
- |> delete_tree(root->right);
- |>
- |> Is this correct or ?
-
- You cannot use `root' after you free it!!! So, your delete_tree(free->right)
- invokes undefined behaviour. You _must_ free root at the end.
-
- |>
- |> And then some problems with strings. Is it common that while
- |> coding using Microsoft Programmers Workbench, strings aren't
- |> what they're supposed to be. For examble, if I use strncat to
- |> cut string from 100 char to 45 char, string is cut, but if I
- |> print it using printf, first 45 chars come out ok, but rest of
- |> the string is filled with smiling faces and all sorts of
- |> 'exotic' characters. Like '\0' isn't there or something...
-
- strncat is supposed to append a '\0'. Could you show some code?
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-